﻿//抵押物区位状况通用下拉框的获取
var uri = document.location.search;//接收页面传值
var i = uri.lastIndexOf("?") + 1;//获取问号前面的值
var P_ReportNumber11 = uri.substr(i);//截取问号前面的值
$(function () {
    $.ajax({
        type: "get",
        url: ApiUrl + "api/Dictionary/GetHouseTypeList",
        data: {
            Dmenuid: [2, 3, 4, 5, 6,31]
        },
        async: false,
        success: function (data, status) {
            if (status == "success") {
                $("option").remove();
                $(data).each(function (i, obj) {
                    $(obj).each(function (j, item) {
                        switch (item.Dmenuid) {
                            case 2:
                                $("#Z_trafficID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 3:
                                $("#Z_natureID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 4:
                                $("#Z_dwellingID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 5:
                                $("#Z_infrastructureID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                      break;
                            case 6:
                                $("#Z_supportingID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 31:
                                $("#surround").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                        }
                    })
                })
            }
        },
        error: function (e) {
            layer.msg('服务器链接超时!', { icon: 0, time: 1000 });
        },
        complete: function () {
        }
    })
})

//抵押物区位状况
function Zone() {
    var Z_master = $("#Z_master").val();                                // （小区四至）东至
    var Z_south = $("#Z_south").val();                                  // （小区四至）南至
    var Z_western = $("#Z_western").val();                              // （小区四至）西至
    var Z_north = $("#Z_north").val();                                  // （小区四至）北至
    var Z_trafficID = $("#Z_trafficID option:checked").attr("value");              // 交通便捷度编号
    var Z_traffic = $("#Z_traffic").val();                              // 交通便捷情况
    var Z_natureID = $("#Z_natureID option:checked").attr("value");                // 自然人文环境编号
    var Z_nature = $("#Z_nature").val();                                // 自然人文环境情况
    var Z_dwellingID = $("#Z_dwellingID option:checked").attr("value");            // 居住社区成熟度编号
    var Z_dwelling = $("#Z_dwelling").val();                            // 居住社区成熟情况
    var Z_infrastructureID = $("#Z_infrastructureID option:checked").attr("value");// 基础设施配套编号
    var Z_infrastructure = $("#Z_infrastructure").val();                // 基础设施配套情况------
    var Z_supportingID = $("#Z_supportingID option:checked").attr("value")         // 配套设施编号
    var Z_surroundID = $("#surround option:checked").attr("value");                 //位置环绕编号
    var Z_explain = $("#surround").val();
    var uri = document.location.search;//接收页面传值
    var i = uri.lastIndexOf("?") + 1;//获取问号前面的值
    var P_ReportNumber11 = uri.substr(i);//截取问号前面的值//其他// 有关说明
    var parms = {
        Z_master: Z_master,                         // （小区四至）东至
        Z_south: Z_south,                           // （小区四至）南至
        Z_western: Z_western,                       // （小区四至）西至
        Z_north: Z_north,                           // （小区四至）北至
        Z_trafficID: Z_trafficID,                   // 交通便捷度编号
        Z_traffic: Z_traffic,                       // 交通便捷情况
        Z_natureID: Z_natureID,                     // 自然人文环境编号
        Z_nature: Z_nature,                         // 自然人文环境情况
        Z_dwellingID: Z_dwellingID,                 // 居住社区成熟度编号
        Z_dwelling: Z_dwelling,                     // 居住社区成熟情况
        Z_infrastructureID: Z_infrastructureID,    // 基础设施配套编号
        Z_infrastructure: Z_infrastructure,         // 基础设施配套情况------
        Z_supportingID: Z_supportingID,             // 配套设施编号
        Z_explain: Z_explain,                  // 有关说明
        P_ReportNumber: P_ReportNumber11,
        Z_surroundID: Z_surroundID,                  //位置环绕编号
    }
    $.ajax({
        type: "post",
        url: ApiUrl + "api/Zone/Postinsert",
        data: parms,
        success: function (data, status) {
            if (status == "success") {
                if (data == true) {
                    layer.msg('保存成功!', { icon: 1, time: 1000 });
                }
                else {
                    layer.msg('保存失败!', { icon: 2, time: 1000 });
                }
            }
        },
        error: function (e) {
            layer.msg('服务器链接超时!', { icon: 0, time: 1000 });
        },
        complete: function () {

        }
    })
}
//数据回填
$(function () {
    //根据报告号判断抵押物区位状况有没有以前填写的数据如果有回填
    $.ajax({
        type: "get",
        url: ApiUrl + "api/Zone/selectbyid",
        data: { P_ReportNumber: P_ReportNumber11 },
        async: false,
        success: function (data, status) {
            if (status == "success") {
                if (data != null) {
                    $("#P_ReportNumber").val(data.P_ReportNumber)
                    $("#Z_master").val(data.Z_master)
                    $("#Z_south").val(data.Z_south)
                    $("#Z_western").val(data.Z_western)
                    $("#Z_north").val(data.Z_north)
                    $("#Z_trafficID").val(data.Z_trafficID)
                    $("#Z_traffic").val(data.Z_traffic)
                    $("#Z_natureID").val(data.Z_natureID)
                    $("#Z_nature").val(data.Z_nature)
                    $("#Z_dwellingID").val(data.Z_dwellingID)
                    $("#Z_dwelling").val(data.Z_dwelling)
                    $("#Z_infrastructureID").val(data.Z_infrastructureID)
                    $("#Z_supportingID").val(data.Z_supportingID)
                    $("#Z_explain").val(data.Z_explain)
                    $("#Z_infrastructure").val(data.Z_infrastructure)
                    $("#Z_state").val(data.Z_state)
                    $("#surround").val(data.Z_surroundID)
                }
            }
        },
        error: function (e) {
            layer.msg('服务器链接超时!', { icon: 2, time: 5000 });
        },
        complete: function () {

        }
    })

})